<template>
    <ve-line
            :data="chartData"
            :extend="extend"
    >

    </ve-line>
</template>

<script>
    import {test, getAll} from '../api/charts'

    export default {
        data() {
            return {
                settings: {
                    metrics: [],
                    dimension: ['dimension']
                },
                extend: {
                    legend: {
                        show: true
                    },
                    toolbox: {
                        show: true,
                        feature: {
                            saveAsImage: {}
                        }
                    },
                    series: {
                        type: 'line',
                        label: {
                            normal: {
                                show: true
                            }
                        }
                    },
                    'xAxis.0.axisLabel.rotate': 25
                },
                chartData: {
                    columns: [],
                    rows: []
                }
            }
        },
        created() {
            test().then(response => {
                console.info(response)
                const data = response.lineVo
                console.info(data)
                const ans = []
                for (let i = 0; i < data.length; i++) {
                    const content = []
                    const item = data[i].content
                    for (let j = 0; j < item.length; j++) {
                        content[item[j].key] = item[j].count
                    }
                    content['index'] = data[i].title
                    ans.push(content)
                }
                console.info(ans)
                this.chartData.rows = ans
                this.chartData.columns = ['index', '测试', '测试es']
            })

            getAll().then(response => {
                // console.info(response)
            })
        },
        methods: {}
    }
</script>
